import { defineConfig ,ConfigEnv} from 'vite'
import { viteMockServe } from 'vite-plugin-mock';
import vue from '@vitejs/plugin-vue'
const url = 'http://192.168.101.61:9999'
const { resolve } = require('path')

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      "@": resolve(__dirname, "./src"),
      "components": resolve(__dirname, "./src/components"),
      "utils": resolve(__dirname, "./src/utils"),
    }
  },
  // ,viteMockServe({
  //   // default
  //   mockPath: 'mock',
  //   localEnabled: true,
  //   prodEnabled:true,
  //   injectCode: `
  //   import { setupProdMockServer } from './mockProdServer';
  //   setupProdMockServer();
  // `,
  // })
  plugins: [vue()],
   /* 打包配置 */
   base: "/huanxing-ui",
   build: {
       brotliSize: false,
       emptyOutDir: false,
       outDir: "dist",
       assetsDir: "static"
   },
  server: {
    port: 8081,
    open: true,   // 是否自动在浏览器打开
    proxy:{
      '/auth': {
        target: url,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/auth/, '')
      },
      '/upms': {
        target: url,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/upms/, '')
      },
      '/malladmin': {
        target: url,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/malladmin/, '')
      },
    }
  }
});